<template>
	<div class="box">
		<HomeFoodTime @transfermealLabel="getmealLabel" :foottimeList="foottimeList" :dataSource="dataSource" :relGroup="relGroup"></HomeFoodTime>
	</div>
</template>

<script>
	import HomeFoodTime from "../../../real-components/HomeFoodTime";
	import { mapGetters } from "vuex";
	import { getPageTree, initDomTree } from "../../../utils/getPageTree";
	import axios from "axios";
	export default {
		props: {
			list: {
				type: Array,
				default: () => []
			},
			relGroup:{
				type:String,
				default:"con004"
			}
		},
		data() {
			return {
				content: '',
				msg: '这是首页',
				page: "home",
				componentName: "HomeFoodTime",
				mealLabel: "",
				/*ids: "",
				targetValue: 0,
				sourceDate: [],*/
				foottimeList: [],
				dataSource: [],
				/*{
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}, {
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}, {
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}, {
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}, {
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}, {
					image: 'static/image/demo1.png',
					goodsname: '',
					normalprice: '',
					goodsunit: '',
				}*/

			}
		},
		computed: {
			...mapGetters([
				"getDomTree"
			]),
			pageTree() {
				return getPageTree(this, this.page);
			}
		},
		components: {
			HomeFoodTime,
		},
		methods: {
			getmealLabel(msg) {
				this.mealLabel = msg;
			},
			setmealLabel() {
				this.$emit('transfermealLabel', this.mealLabel)
			},
			queryfoodtima() {
				this.foottimeList=[]
				this.dataSource=[]
				/*var listlength= this.list.length<6?this.list.length:6*/
				for(var i = 0; i < this.list.length; i++) {
					if(this.list[i].relPosition=="title"){
						this.foottimeList.push(this.list[i])
					}else if(this.list[i].relPosition=="content"){
						this.dataSource.push(this.list[i])
					}
				}
			},
			/*queryMeal(datatime) {
				axios.post(api.local_host + '/resourceLevel/selectMeal', {
					enterpriseId: api.enterpriseId,
					mealLabel: datatime
				}).then((res) => {
					if(datatime.indexOf("Title") > 0) {
						if(this.foottimeList) {
							this.foottimeList = res.data.data[0]
						}
					} else {
						this.sourceDate = res.data.data[0]
						for(var i = 0; i < this.sourceDate.length; i++) {
							this.ids += this.sourceDate[i].goodsNo + ','
						}
						this.renderGood(this.ids)
					}
				})
			},*/

			/*renderGood(ids) {
				var self=this
				axios.get(api.mall_goods_host + '/goodsRestApi/queryGoodsList?enterpriseid=' + api.enterpriseid + "&goodscode=" + ids).then((res) => {
					this.dataSource = res.data.data
					let arr = [];
					for(var j = 0; j < self.sourceDate.length; j++) {
						for(var i = 0; i < this.dataSource.length; i++) {
							if(parseInt(this.dataSource[i].goodscode)==parseInt(self.sourceDate[j].goodsNo)){
								this.dataSource[i].image=this.sourceDate[j].image;
								this.dataSource[i].promotionType=this.sourceDate[j].promotionType
								arr.push(this.dataSource[i]);
							}
						}
					}
					this.dataSource = arr;
				})
				
			},*/

		},
		watch: {
			mealLabel() {
				this.setmealLabel()
			},
			list() {
				this.queryfoodtima()
			}
		},
		created() {
			this.setmealLabel()
		},
		mounted() { // initDomTree(this.getDomTree[this.page]);
			/*this.queryMeal(this.mealLabel + 'Title');
			this.queryMeal(this.mealLabel);*/
			this.queryfoodtima()
		},
		updated() {
			//页面更新完毕
			// initDomTree(this.getDomTree[this.page]);
		}
	}
</script>

<style>

</style>